scheduler: decouple the keyranges with different schedulers#9330
scheduler: decouple the keyranges with different schedulers#9330ti-chi-bot[bot] merged 19 commits intotikv:masterfrom
Conversation
Signed-off-by: 童剑 <[email protected]>
Signed-off-by: 童剑 <[email protected]>
Signed-off-by: 童剑 <[email protected]>
Signed-off-by: 童剑 <[email protected]>
Signed-off-by: 童剑 <[email protected]>
Signed-off-by: 童剑 <[email protected]>
Signed-off-by: 童剑 <[email protected]>
|
Skipping CI for Draft Pull Request. |
7fa0925 to
808b7a1
Compare
Signed-off-by: 童剑 <[email protected]>
808b7a1 to
dbff105
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9330 +/- ##
==========================================
- Coverage 76.18% 76.18% -0.01%
==========================================
Files 478 479 +1
Lines 74794 74988 +194
==========================================
+ Hits 56984 57129 +145
- Misses 14282 14314 +32
- Partials 3528 3545 +17
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Signed-off-by: 童剑 <[email protected]>
885ffe7 to
51f06d1
Compare
Signed-off-by: 童剑 <[email protected]>
51f06d1 to
01f2334
Compare
Signed-off-by: 童剑 <[email protected]>
| ) | ||
|
|
||
| // KeyRangeManager is a manager for key ranges. | ||
| type KeyRangeManager struct { |
There was a problem hiding this comment.
Seems keyutil is a more proper package?
There was a problem hiding this comment.
moved to the new pkg pkg/schedule/rangelist
| func (s *balanceLeaderScheduler) transferLeaderOut(solver *solver, collector *plan.Collector) *operator.Operator { | ||
| solver.Region = filter.SelectOneRegion(solver.RandLeaderRegions(solver.sourceStoreID(), s.conf.getRanges()), | ||
| rs := s.conf.getRanges() | ||
| if IsDefaultKeyRange(rs) { |
There was a problem hiding this comment.
How about the hot region scheduler?
There was a problem hiding this comment.
Hot region scheduler can schedule all the regions, not restricting this limit.
Signed-off-by: 童剑 <[email protected]>
|
ping @rleungx again |
| for _, r := range rs { | ||
| s.sortedKeyRanges.Append(r.StartKey, r.EndKey) | ||
| } | ||
| s.sortedKeyRanges.SortAndDeduce() |
There was a problem hiding this comment.
For every time we append, we need to sort?
There was a problem hiding this comment.
done, using adjust function to check the two regions
Signed-off-by: 童剑 <[email protected]>
Signed-off-by: 童剑 <[email protected]>
pkg/utils/keyutil/util.go
Outdated
|
|
||
| // MaxKeyWithBoundary returns the bigger key for the given keys. | ||
| // it is different from MaxKey, if the key is empty and the boundary is right, the empty key is biggest, | ||
| func MaxKeyWithBoundary(a, b []byte, opt boundary) []byte { |
There was a problem hiding this comment.
How about changing to MaxStartKey/MinEndKey? The boundary is useless.
pkg/utils/keyutil/keyrange.go
Outdated
| for i := 1; i < len(rs.krs); i++ { | ||
| last := res[len(res)-1] | ||
| if last.IsAdjacent(rs.krs[i]) { | ||
| last.StartKey = MinKeyWithBoundary(last.StartKey, rs.krs[i].StartKey, left) |
There was a problem hiding this comment.
It has already been sorted, no need to compare?
| rs := s.conf.getRanges() | ||
| if IsDefaultKeyRange(rs) { | ||
| km := solver.GetKeyRangeManager() | ||
| rs = km.GetNonOverlappingKeyRanges(&rs[0]) |
There was a problem hiding this comment.
Will it slow down the balance leader's speed?
There was a problem hiding this comment.
If one balance-keyrange job is running, the pick ranges of the scheduling regions become small. Otherwise, the rs is the same with the master; this function does not influence the select the source region.
| solver.Step++ | ||
| var sourceIndex int | ||
|
|
||
| rs := s.conf.Ranges |
There was a problem hiding this comment.
What if we change the range manually?
There was a problem hiding this comment.
The config can only be changed by the scatter range scheduler. This scatter scheduler only picks the given key-range regions, there is no any conflict
There was a problem hiding this comment.
I think this config is exposed. We can set them through pd-ctl.
There was a problem hiding this comment.
Yes, I used the scheduler name to distinguish the scheduler from the scatter-scheduler
Signed-off-by: 童剑 <[email protected]>
6e774db to
9db3d05
Compare
Signed-off-by: 童剑 <[email protected]>
e93b5b6 to
255029d
Compare
| rs := s.conf.getRanges() | ||
| if s.GetName() == types.BalanceLeaderScheduler.String() { | ||
| km := solver.GetKeyRangeManager() | ||
| rs = km.GetNonOverlappingKeyRanges(&rs[0]) |
There was a problem hiding this comment.
How about skipping it if there is no job?
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lhy1024, rleungx The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
3a92d59 to
3706344
Compare
Signed-off-by: 童剑 <[email protected]>
7bda573 to
394843c
Compare
854a502 to
357c741
Compare
What problem does this PR solve?
Issue Number: Close #9302
What is changed and how does it work?
Check List
Tests
Code changes
Side effects
Related changes
pingcap/docs/pingcap/docs-cn:pingcap/tiup:Release note